//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.mega.ycy.network;

import com.mega.ycy.GuiGameOver;
import com.mega.ycy.Saver;
import com.mega.ycy.Yiciyuan_EVENT;
import com.mega.ycy.mixin.TWEAKER;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class KillMessage implements IMessage {
    public int id;

    public KillMessage() {
    }

    public KillMessage(int id) {
        this.id = id;
    }

    public void fromBytes(ByteBuf buf) {
        id = buf.readInt();
    }

    public void toBytes(ByteBuf buf) {
        buf.writeInt(id);
    }

    public static class MessageHandler implements IMessageHandler<KillMessage, IMessage> {
        public MessageHandler() {
        }

        public IMessage onMessage(KillMessage m, MessageContext ctx) {
            Yiciyuan_EVENT.killEntity(Minecraft.getMinecraft().world.playerEntities.get(m.id));
            if (!Yiciyuan_EVENT.isSafe(Minecraft.getMinecraft().player))
                Yiciyuan_EVENT.SCREEN = new Saver(new GuiGameOver(null));
            return null;
        }
    }
}
